package demo10;

public class OrderedMatrix {
    public OrderedMatrixDemo1 createOrderedMatrixDemo1(){
        return new OrderedMatrixDemo1();
    }
    public class OrderedMatrixDemo1{

        public int[][] create(){
            int n =3 ;
            int m = 4;
            int[][] martix  = new int[n][m];
            /**
             *
             */
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    martix[i][j]= (i + 1) + (j );
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                   System.out.print(martix[i][j]);
                   System.out.print(",");
                }
                System.out.println();
            }
            return martix;
        }
        /**
         * M * N
         * answer:
         * 1.foreach  yes ,
         * 2.binarySearch
         * step1.
         *   every row and every column should be ordered
         *   you can use binarySearch , search (all of row) or (all of column)
         *  Timing:  search (all of row): O(n * m * logm)
         *  Timing:  search (all of column): O(m * n * logn)
         * step2.
         *  get the start and end , ensure if contains  the number
         * step3:
         *  using the array to record ,
         *  advantages:
         *      扁平,好管理
         *  disadvantages:
         *
         *
         * matrix have  ordered , search number,
         * app:
         * todo look:
         *  spark ,
         */

        public void findNumber(int[][] martix,int number){
            /**
             * martix[0][]
             * martix[][1]
             */

        }
    }
}
